home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb.new / gdb-4.0 / gdb / gdb.info-3 < prev    next >
Encoding:
Text File  |  1991-08-24  |  48.5 KB  |  1,313 lines

  1. Info file gdb.info, produced by Makeinfo, -*- Text -*- from input
  2. file gdb-all.texi.
  3.  
  4.    This file documents the GNU debugger GDB.
  5.  
  6.    Copyright (C) 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of
  9. this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this
  15. manual under the conditions for verbatim copying, provided also that
  16. the section entitled "GNU General Public License" is included
  17. exactly as in the original, and provided that the entire resulting
  18. derived work is distributed under the terms of a permission notice
  19. identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for
  23. modified versions, except that the section entitled "GNU General
  24. Public License" may be included in a translation approved by the
  25. Free Software Foundation instead of in the original English.
  26.  
  27. 
  28. File: gdb.info,  Node: Source Path,  Next: Machine Code,  Prev: Search,  Up: Source
  29.  
  30. Specifying Source Directories
  31. =============================
  32.  
  33.    Executable programs sometimes do not record the directories of the
  34. source files from which they were compiled, just the names.  Even
  35. when they do, the directories could be moved between the compilation
  36. and your debugging session.  GDB has a list of directories to search
  37. for source files; this is called the "source path".  Each time GDB
  38. wants a source file, it tries all the directories in the list, in
  39. the order they are present in the list, until it finds a file with
  40. the desired name.  Note that the executable search path is *not*
  41. used for this purpose.  Neither is the current working directory,
  42. unless it happens to be in the source path.
  43.  
  44.    If GDB can't find a source file in the source path, and the object
  45. program records a directory, GDB tries that directory too.  If the
  46. source path is empty, and there is no record of the compilation
  47. directory, GDB will, as a last resort, look in the current directory.
  48.  
  49.    Whenever you reset or rearrange the source path, GDB will clear
  50. out any information it has cached about where source files are
  51. found, where each line is in the file, etc.
  52.  
  53.    When you start GDB, its source path is empty.  To add other
  54. directories, use the `directory' command.
  55.  
  56. `directory DIRNAME ...'
  57.      Add directory DIRNAME to the front of the source path.  Several
  58.      directory names may be given to this command, separated by `:'
  59.      or whitespace.  You may specify a directory that is already in
  60.      the source path; this moves it forward, so it will be searched
  61.      sooner.
  62.  
  63.      You can use the string `$cdir' to refer to the compilation
  64.      directory (if one is recorded), and `$cwd' to refer to the
  65.      current working directory.  `$cwd' is not the same as `.'--the
  66.      former tracks the current working directory as it changes
  67.      during your GDB session, while the latter is immediately
  68.      expanded to the current directory at the time you add an entry
  69.      to the source path.
  70.  
  71. `directory'
  72.      Reset the source path to empty again.  This requires confirmation.
  73.  
  74. `show directories'
  75.      Print the source path: show which directories it contains.
  76.  
  77.    If your source path is cluttered with directories that are no
  78. longer
  79. of interest, GDB may sometimes cause confusion by finding the wrong
  80. versions of source.  You can correct the situation as follows:
  81.  
  82.   1. Use `directory' with no argument to reset the source path to
  83.      empty.
  84.  
  85.   2. Use `directory' with suitable arguments to reinstall the
  86.      directories you want in the source path.  You can add all the
  87.      directories in one command.
  88.  
  89. 
  90. File: gdb.info,  Node: Machine Code,  Prev: Source Path,  Up: Source
  91.  
  92. Source and Machine Code
  93. =======================
  94.  
  95.    You can use the command `info line' to map source lines to program
  96. addresses
  97. (and viceversa), and the command `disassemble' to display a range of
  98. addresses as machine instructions.
  99.  
  100. `info line LINESPEC'
  101.      Print the starting and ending addresses of the compiled code for
  102.      source line LINESPEC.  You can specify source lines in any of
  103.      the ways understood by the `list' command (*note List::.).
  104.  
  105.    For example, we can use `info line' to inquire on where the object
  106. code for the first line of function `m4_changequote' lies:
  107.  
  108.      (gdb) info line m4_changecom
  109.      Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350.
  110.  
  111. We can also inquire (using `*ADDR' as the form for LINESPEC) what
  112. source line covers a particular address:
  113.  
  114.      (gdb) info line *0x63ff
  115.      Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404.
  116.  
  117.    After `info line', the default address for the `x' command is
  118. changed to the starting address of the line, so that `x/i' is
  119. sufficient to begin examining the machine code (*note Memory::.). 
  120. Also, this address is saved as the value of the convenience variable
  121. `$_' (*note Convenience Vars::.).
  122.  
  123. `disassemble'
  124.      This specialized command is provided to dump a range of memory
  125.      as machine instructions.  The default memory range is the
  126.      function surrounding the program counter of the selected frame.
  127.      A single argument to this command is a program counter value;
  128.      the function surrounding this value will be dumped.  Two
  129.      arguments (separated by one or more spaces) specify a range of
  130.      addresses (first inclusive, second exclusive) to be dumped.
  131.  
  132.    We can use `disassemble' to inspect the object code range shown in
  133. the last `info line' example:
  134.  
  135.      (gdb) disas 0x63e4 0x6404
  136.      Dump of assembler code from 0x63e4 to 0x6404:
  137.      0x63e4 builtin_init+5340:     ble 0x63f8 builtin_init+5360
  138.      0x63e8 builtin_init+5344:     sethi %hi(0x4c00), %o0
  139.      0x63ec builtin_init+5348:     ld [%i1+4], %o0
  140.      0x63f0 builtin_init+5352:     b 0x63fc builtin_init+5364
  141.      0x63f4 builtin_init+5356:     ld [%o0+4], %o0
  142.      0x63f8 builtin_init+5360:     or %o0, 0x1a4, %o0
  143.      0x63fc builtin_init+5364:     call 0x9288 path_search
  144.      0x6400 builtin_init+5368:     nop 
  145.      End of assembler dump.
  146.      (gdb)
  147.  
  148. 
  149. File: gdb.info,  Node: Data,  Next: Cplusplus,  Prev: Source,  Up: Top
  150.  
  151. Examining Data
  152. **************
  153.  
  154.    The usual way to examine data in your program is with the `print'
  155. command (abbreviated `p'), or its synonym `inspect'.  It evaluates
  156. and prints the value of an expression of the language your program
  157. is written in (for now, C or C++).  You type
  158.  
  159.      print EXP
  160.  
  161. where EXP is an expression (in the source language), and the value of
  162. EXP is printed in a format appropriate to its data type.
  163.  
  164.    A more low-level way of examining data is with the `x' command. 
  165. It examines data in memory at a specified address and prints it in a
  166. specified format.  *Note Memory::.
  167.  
  168.    If you're interested in information about types, or about how the
  169. fields of a struct or class are declared, use the `ptype EXP'
  170. command rather than `print'. *Note Symbols::.
  171.  
  172. * Menu:
  173.  
  174. * Expressions::                 Expressions
  175. * Variables::                   Program Variables
  176. * Arrays::                      Artificial Arrays
  177. * Output formats::              Output formats
  178. * Memory::                      Examining Memory
  179. * Auto Display::                Automatic Display
  180. * Print Settings::              Print Settings
  181. * Value History::               Value History
  182. * Convenience Vars::            Convenience Variables
  183. * Registers::                   Registers
  184. * Floating Point Hardware::     Floating Point Hardware
  185.  
  186. 
  187. File: gdb.info,  Node: Expressions,  Next: Variables,  Prev: Data,  Up: Data
  188.  
  189. Expressions
  190. ===========
  191.  
  192.    `print' and many other GDB commands accept an expression and
  193. compute its value.  Any kind of constant, variable or operator
  194. defined by the programming language you are using is legal in an
  195. expression in GDB.  This includes conditional expressions, function
  196. calls, casts and string constants.  It unfortunately does not
  197. include symbols defined by preprocessor `#define' commands.
  198.  
  199.    Casts are supported in all languages, not just in C, because it is
  200. so useful to cast a number into a pointer so as to examine a
  201. structure at that address in memory.
  202.  
  203.    GDB supports three kinds of operator in addition to those of
  204. programming languages:
  205.  
  206. `@'
  207.      `@' is a binary operator for treating parts of memory as arrays.
  208.      *Note Arrays::, for more information.
  209.  
  210. `::'
  211.      `::' allows you to specify a variable in terms of the file or
  212.      function where it is defined.  *Note Variables::.
  213.  
  214. `{TYPE} ADDR'
  215.      Refers to an object of type TYPE stored at address ADDR in
  216.      memory.  ADDR may be any expression whose value is an integer
  217.      or pointer (but parentheses are required around binary
  218.      operators, just as in a cast).  This construct is allowed
  219.      regardless of what kind of data is normally supposed to reside
  220.      at ADDR.
  221.  
  222. 
  223. File: gdb.info,  Node: Variables,  Next: Arrays,  Prev: Expressions,  Up: Data
  224.  
  225. Program Variables
  226. =================
  227.  
  228.    The most common kind of expression to use is the name of a
  229. variable in your program.
  230.  
  231.    Variables in expressions are understood in the selected stack
  232. frame (*note Selection::.); they must either be global (or static)
  233. or be visible according to the scope rules of the programming
  234. language from the point of execution in that frame.  This means that
  235. in the function
  236.  
  237.      foo (a)
  238.           int a;
  239.      {
  240.        bar (a);
  241.        {
  242.          int b = test ();
  243.          bar (b);
  244.        }
  245.      }
  246.  
  247. the variable `a' is usable whenever the program is executing within
  248. the function `foo', but the variable `b' is visible only while the
  249. program is executing inside the block in which `b' is declared.
  250.  
  251.    There is an exception: you can refer to a variable or function
  252. whose scope is a single source file even if the current execution
  253. point is not in this file.  But it is possible to have more than one
  254. such variable or function with the same name (in different source
  255. files).  If that happens, referring to that name has unpredictable
  256. effects.  If you wish, you can specify a variable in a particular
  257. file, using the colon-colon notation:
  258.  
  259.      FILE::VARIABLE
  260.  
  261. Here FILE is the name of the source file whose variable you want.
  262.  
  263.    This use of `::' is very rarely in conflict with the very similar
  264. use of the same notation in C++.  GDB also supports use of the C++
  265. name resolution operator in GDB expressions.
  266.  
  267.      *Warning:* Occasionally, a local variable may appear to have the
  268.      wrong value at certain points in a function--just after entry
  269.      to the function, and just before exit.  You may see this
  270.      problem when you're stepping by machine instructions.  This is
  271.      because on most machines, it takes more than one instruction to
  272.      set up a stack frame (including local variable definitions); if
  273.      you're stepping by machine instructions, variables may appear
  274.      to have the wrong values until the stack frame is completely
  275.      built.  On function exit, it usually also takes more than one
  276.      machine instruction to destroy a stack frame; after you begin
  277.      stepping through that group of instructions, local variable
  278.      definitions may be gone.
  279.  
  280. 
  281. File: gdb.info,  Node: Arrays,  Next: Output formats,  Prev: Variables,  Up: Data
  282.  
  283. Artificial Arrays
  284. =================
  285.  
  286.    It is often useful to print out several successive objects of the
  287. same type in memory; a section of an array, or an array of
  288. dynamically determined size for which only a pointer exists in the
  289. program.
  290.  
  291.    This can be done by constructing an "artificial array" with the
  292. binary operator `@'.  The left operand of `@' should be the first
  293. element of the desired array, as an individual object.  The right
  294. operand
  295. should be the desired length of the array.  The result is an array
  296. value whose elements are all of the type of the left argument.  The
  297. first element is actually the left argument; the second element
  298. comes from bytes of memory immediately following those that hold the
  299. first element, and so on.  Here is an example.  If a program says
  300.  
  301.      int *array = (int *) malloc (len * sizeof (int));
  302.  
  303. you can print the contents of `array' with
  304.  
  305.      p *array@len
  306.  
  307.    The left operand of `@' must reside in memory.  Array values made
  308. with `@' in this way behave just like other arrays in terms of
  309. subscripting, and are coerced to pointers when used in expressions. 
  310. Artificial arrays most often appear in expressions via the value
  311. history (*note Value History::.), after printing one out.)
  312.  
  313.    Sometimes the artificial array mechanism isn't quite enough; in
  314. moderately complex data structures, the elements of interest may not
  315. actually be adjacent--for example, if you're interested in the
  316. values of pointers in an array.  One useful work-around in this
  317. situation is to use a convenience variable (*note Convenience
  318. Vars::.) as a counter in an expression that prints the first
  319. interesting value, and then repeat that expression via RET.  For
  320. instance, suppose you have an array `dtab' of pointers to
  321. structures, and you're interested in the values of a field `fv' in
  322. each structure.  Here's an example of what you might type:
  323.  
  324.      set $i = 0
  325.      p dtab[$i++]->fv
  326.      RET
  327.      RET
  328.      ...
  329.  
  330. 
  331. File: gdb.info,  Node: Output formats,  Next: Memory,  Prev: Arrays,  Up: Data
  332.  
  333. Output formats
  334. ==============
  335.  
  336.    By default, GDB prints a value according to its data type. 
  337. Sometimes this is not what you want.  For example, you might want to
  338. print a number in hex, or a pointer in decimal.  Or you might want
  339. to view data in memory at a certain address as a character string or
  340. as an instruction.  To do these things, specify an "output format"
  341. when you print a value.
  342.  
  343.    The simplest use of output formats is to say how to print a value
  344. already computed.  This is done by starting the arguments of the
  345. `print' command with a slash and a format letter.  The format
  346. letters supported are:
  347.  
  348. `x'
  349.      Regard the bits of the value as an integer, and print the
  350.      integer in hexadecimal.
  351.  
  352. `d'
  353.      Print as integer in signed decimal.
  354.  
  355. `u'
  356.      Print as integer in unsigned decimal.
  357.  
  358. `o'
  359.      Print as integer in octal.
  360.  
  361. `t'
  362.      Print as integer in binary.  The letter `t' stands for "two".
  363.  
  364. `a'
  365.      Print as an address, both absolute in hex and as an offset from
  366.      the nearest preceding symbol.  This format can be used to
  367.      discover where (in what function) an unknown address is located:
  368.  
  369.           (gdb) p/a 0x54320
  370.           $3 = 0x54320 <_initialize_vx+396>
  371.  
  372. `c'
  373.      Regard as an integer and print it as a character constant.
  374.  
  375. `f'
  376.      Regard the bits of the value as a floating point number and
  377.      print
  378.      using typical floating point syntax.
  379.  
  380.    For example, to print the program counter in hex (*note
  381. Registers::.), type
  382.  
  383.      p/x $pc
  384.  
  385. Note that no space is required before the slash; this is because
  386. command names in GDB cannot contain a slash.
  387.  
  388.    To reprint the last value in the value history with a different
  389. format, you can use the `print' command with just a format and no
  390. expression.  For example, `p/x' reprints the last value in hex.
  391.  
  392. 
  393. File: gdb.info,  Node: Memory,  Next: Auto Display,  Prev: Output formats,  Up: Data
  394.  
  395. Examining Memory
  396. ================
  397.  
  398. `x/NFU EXPR'
  399.      The command `x' (for `examine') can be used to examine memory
  400.      without being constrained by your program's data types.  You
  401.      can specify the unit size U of memory to inspect, and a repeat
  402.      count N of how many of those units to display.  `x' understands
  403.      the formats F used by `print'; two additional formats, `s'
  404.      (string) and `i' (machine instruction) can be used without
  405.      specifying a unit size.
  406.  
  407.    For example, `x/3uh 0x54320' is a request to display three
  408. halfwords (`h') of memory, formatted as unsigned decimal integers
  409. (`u'),
  410. starting at address `0x54320'.  `x/4xw $sp' prints the four words
  411. (`w') of memory above the stack pointer (here, `$sp'; *note
  412. Registers::.) in hexadecimal (`x').
  413.  
  414.    Since the letters indicating unit sizes are all distinct from the
  415. letters specifying output formats, you don't have to remember
  416. whether unit size or format comes first; either order will work. 
  417. The output specifications `4xw' and `4wx' mean exactly the same thing.
  418.  
  419.    After the format specification, you supply an expression for the
  420. address where GDB is to begin reading from memory.  The expression
  421. need not have a pointer value (though it may); it is always
  422. interpreted as an integer address of a byte of memory.  *Note
  423. Expressions:: for more information on expressions.
  424.  
  425.    These are the memory units U you can specify with the `x' command:
  426.  
  427. `b'
  428.      Examine individual bytes.
  429.  
  430. `h'
  431.      Examine halfwords (two bytes each).
  432.  
  433. `w'
  434.      Examine words (four bytes each).
  435.  
  436.      Many assemblers and cpu designers still use `word' for a 16-bit
  437.      quantity, as a holdover from specific predecessor machines of
  438.      the 1970's that really did use two-byte words.  But more
  439.      generally the term `word' has always referred to the size of
  440.      quantity that a machine normally operates on and stores in its
  441.      registers.  This is 32 bits for all the machines that GDB runs
  442.      on.
  443.  
  444. `g'
  445.      Examine giant words (8 bytes).
  446.  
  447.    You can combine these unit specifications with any of the formats
  448. described for `print'.  *Note Output formats::.
  449.  
  450.    `x' has two additional output specifications which derive the unit
  451. size from the data inspected:
  452.  
  453. `s'
  454.      Print a null-terminated string of characters.  Any explicitly
  455.      specified unit size is ignored; instead, the unit is however
  456.      many bytes it takes to reach a null character (including the
  457.      null character).
  458.  
  459. `i'
  460.      Print a machine instruction in assembler syntax (or nearly). 
  461.      Any specified unit size is ignored; the number of bytes in an
  462.      instruction varies depending on the type of machine, the opcode
  463.      and the addressing modes used.  The command `disassemble' gives
  464.      an alternative way of inspecting machine instructions.  *Note
  465.      Machine Code::.
  466.  
  467.    If you omit either the format F or the unit size U, `x' will use
  468. the same one that was used last.  If you don't use any letters or
  469. digits after the slash, you can omit the slash as well.
  470.  
  471.    You can also omit the address to examine.  Then the address used
  472. is just after the last unit examined.  This is why string and
  473. instruction formats actually compute a unit-size based on the data:
  474. so that the next string or instruction examined will start in the
  475. right place.
  476.  
  477.    When the `print' command shows a value that resides in memory,
  478. `print' also sets the default address for the `x' command.  `info
  479. line' also sets the default for `x', to the address of the start of
  480. the machine code for the specified line (*note Machine Code::.), and
  481. `info breakpoints' sets it to the address of the last breakpoint
  482. listed (*note Set Breaks::.).
  483.  
  484.    When you use RET to repeat an `x' command, the address specified
  485. previously (if any) is ignored, so that the repeated command
  486. examines the successive locations in memory rather than the same ones.
  487.  
  488.    You can examine several consecutive units of memory with one
  489. command by writing a repeat-count after the slash (before the format
  490. letters, if any).  Omitting the repeat count N displays one unit of
  491. the appropriate size.  The repeat count must be a decimal integer. 
  492. It has the same effect as repeating the `x' command N times except
  493. that the output may be more compact, with several units per line. 
  494. For example,
  495.  
  496.      x/10i $pc
  497.  
  498. prints ten instructions starting with the one to be executed next in
  499. the selected frame.  After doing this, you could print a further
  500. seven instructions with
  501.  
  502.      x/7
  503.  
  504. --where the format and address are allowed to default.
  505.  
  506.    The addresses and contents printed by the `x' command are not put
  507. in the value history because there is often too much of them and
  508. they would get in the way.  Instead, GDB makes these values
  509. available for subsequent use in expressions as values of the
  510. convenience variables `$_' and `$__'.  After an `x' command, the
  511. last address examined is available for use in expressions in the
  512. convenience variable `$_'.  The contents of that address, as
  513. examined, are available in the convenience variable `$__'.
  514.  
  515.    If the `x' command has a repeat count, the address and contents
  516. saved are from the last memory unit printed; this is not the same as
  517. the last address printed if several units were printed on the last
  518. line of output.
  519.  
  520. 
  521. File: gdb.info,  Node: Auto Display,  Next: Print Settings,  Prev: Memory,  Up: Data
  522.  
  523. Automatic Display
  524. =================
  525.  
  526.    If you find that you want to print the value of an expression
  527. frequently (to see how it changes), you might want to add it to the
  528. "automatic
  529. display list" so that GDB will print its value each time the program
  530. stops.  Each expression added to the list is given a number to
  531. identify it; to remove an expression from the list, you specify that
  532. number.  The automatic display looks like this:
  533.  
  534.      2: foo = 38
  535.      3: bar[5] = (struct hack *) 0x3804
  536.  
  537. showing item numbers, expressions and their current values.  As with
  538. displays you request manually using `x' or `print', you can specify
  539. the output format you prefer; in fact, `display' decides whether to
  540. use `print' or `x' depending on how elaborate your format
  541. specification
  542. is--it uses `x' if you specify a unit size, or one of the two
  543. formats (`i' and `s') that are only supported by `x'; otherwise it
  544. uses `print'.
  545.  
  546. `display EXP'
  547.      Add the expression EXP to the list of expressions to display
  548.      each time the program stops.  *Note Expressions::.
  549.  
  550.      `display' will not repeat if you press RET again after using it.
  551.  
  552. `display/FMT EXP'
  553.      For FMT specifying only a display format and not a size or
  554.      count, add the expression EXP to the auto-display list but
  555.      arranges to display it each time in the specified format FMT. 
  556.      *Note Output formats::.
  557.  
  558. `display/FMT ADDR'
  559.      For FMT `i' or `s', or including a unit-size or a number of
  560.      units, add the expression ADDR as a memory address to be
  561.      examined each time the program stops.  Examining means in
  562.      effect doing `x/FMT ADDR'.  *Note Memory::.
  563.  
  564.    For example, `display/i $pc' can be helpful, to see the machine
  565. instruction about to be executed each time execution stops (`$pc' is
  566. a common name for the program counter; *note Registers::.).
  567.  
  568. `undisplay DNUMS...'
  569. `delete display DNUMS...'
  570.      Remove item numbers DNUMS from the list of expressions to display.
  571.  
  572.      `undisplay' will not repeat if you press RET after using it. 
  573.      (Otherwise you would just get the error `No display number ...'.)
  574.  
  575. `disable display DNUMS...'
  576.      Disable the display of item numbers DNUMS.  A disabled display
  577.      item is not printed automatically, but is not forgotten.  It
  578.      may be enabled again later.
  579.  
  580. `enable display DNUMS...'
  581.      Enable display of item numbers DNUMS.  It becomes effective once
  582.      again in auto display of its expression, until you specify
  583.      otherwise.
  584.  
  585. `display'
  586.      Display the current values of the expressions on the list, just
  587.      as is done when the program stops.
  588.  
  589. `info display'
  590.      Print the list of expressions previously set up to display
  591.      automatically, each one with its item number, but without
  592.      showing the values.  This includes disabled expressions, which
  593.      are marked as such.  It also includes expressions which would
  594.      not be displayed right now because they refer to automatic
  595.      variables not currently available.
  596.  
  597.    If a display expression refers to local variables, then it does
  598. not make sense outside the lexical context for which it was set up. 
  599. Such an expression is disabled when execution enters a context where
  600. one of its variables is not defined.  For example, if you give the
  601. command `display last_char' while inside a function with an argument
  602. `last_char', then this argument will be displayed while the program
  603. continues to stop inside that function.  When it stops
  604. elsewhere--where there is no variable `last_char'--display is
  605. disabled.  The next time your program stops where `last_char' is
  606. meaningful, you can enable the display expression once again.
  607.  
  608. 
  609. File: gdb.info,  Node: Print Settings,  Next: Value History,  Prev: Auto Display,  Up: Data
  610.  
  611. Print Settings
  612. ==============
  613.  
  614.    GDB provides the following ways to control how arrays, structures,
  615. and symbols are printed.
  616.  
  617. These settings are useful for debugging programs in any language:
  618.  
  619. `set print address'
  620. `set print address on'
  621.      GDB will print memory addresses showing the location of stack
  622.      traces, structure values, pointer values, breakpoints, and so
  623.      forth, even when it also displays the contents of those
  624.      addresses.  The default is on.  For example, this is what a
  625.      stack frame display looks like, with `set print address on':
  626.  
  627.           (gdb) f
  628.           #0  set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>") 
  629.               at input.c:530
  630.           530         if (lquote != def_lquote)
  631.  
  632. `set print address off'
  633.      Do not print addresses when displaying their contents.  For
  634.      example, this is the same stack frame displayed with `set print
  635.      address off':
  636.  
  637.           (gdb) set print addr off
  638.           (gdb) f
  639.           #0  set_quotes (lq="<<", rq=">>") at input.c:530
  640.           530         if (lquote != def_lquote)
  641.  
  642. `show print address'
  643.      Show whether or not addresses are to be printed.
  644.  
  645. `set print array'
  646. `set print array on'
  647.      GDB will pretty print arrays.  This format is more convenient to
  648.      read, but uses more space.  The default is off.
  649.  
  650. `set print array off.'
  651.      Return to compressed format for arrays.
  652.  
  653. `show print array'
  654.      Show whether compressed or pretty format is selected for
  655.      displaying arrays.
  656.  
  657. `set print elements NUMBER-OF-ELEMENTS'
  658.      If GDB is printing a large array, it will stop printing after it
  659.      has printed the number of elements set by the `set print
  660.      elements' command.  This limit also applies to the display of
  661.      strings.
  662.  
  663. `show print elements'
  664.      Display the number of elements of a large array that GDB will
  665.      print before losing patience.
  666.  
  667. `set print pretty on'
  668.      Cause GDB to print structures in an indented format with one
  669.      member per line, like this:
  670.  
  671.           $1 = {
  672.             next = 0x0,
  673.             flags = {
  674.               sweet = 1,
  675.               sour = 1
  676.             },
  677.             meat = 0x54 "Pork"
  678.           }
  679.  
  680. `set print pretty off'
  681.      Cause GDB to print structures in a compact format, like this:
  682.  
  683.           $1 = {next = 0x0, flags = {sweet = 1, sour = 1}, meat \
  684.           = 0x54 "Pork"}
  685.  
  686.      This is the default format.
  687.  
  688. `show print pretty'
  689.      Show which format GDB will use to print structures.
  690.  
  691. `set print sevenbit-strings on'
  692.      Print using only seven-bit characters; if this option is set, 
  693.      GDB will display any eight-bit characters (in strings or
  694.      character values) using the notation `\'NNN.  For example,
  695.      `M-a' is displayed as `\341'.
  696.  
  697. `set print sevenbit-strings off'
  698.      Print using either seven-bit or eight-bit characters, as
  699.      required.  This is the default.
  700.  
  701. `show print sevenbit-strings'
  702.      Show whether or not GDB will print only seven-bit characters.
  703.  
  704. `set print union on'
  705.      Tell GDB to print unions which are contained in structures. 
  706.      This is the default setting.
  707.  
  708. `set print union off'
  709.      Tell GDB not to print unions which are contained in structures.
  710.  
  711. `show print union'
  712.      Ask GDB whether or not it will print unions which are contained
  713.      in structures.
  714.  
  715.      For example, given the declarations
  716.  
  717.           typedef enum {Tree, Bug} Species;
  718.           typedef enum {Big_tree, Acorn, Seedling} Tree_forms;
  719.           typedef enum {Caterpillar, Cocoon, Butterfly} Bug_forms;
  720.           
  721.           struct thing {
  722.             Species it;
  723.             union {
  724.               Tree_forms tree;
  725.               Bug_forms bug;
  726.             } form;
  727.           };
  728.           
  729.           struct thing foo = {Tree, {Acorn}};
  730.  
  731.      with `set print union on' in effect `p foo' would print
  732.  
  733.           $1 = {it = Tree, form = {tree = Acorn, bug = Cocoon}}
  734.  
  735.      and with `set print union off' in effect it would print
  736.  
  737.           $1 = {it = Tree, form = {...}}
  738.  
  739. These settings are of interest when debugging C++ programs:
  740.  
  741. `set print demangle'
  742. `set print demangle on'
  743.      Print C++ names in their source form rather than in the mangled
  744.      form in which they are passed to the assembler and linker for
  745.      type-safe linkage.  The default is on.
  746.  
  747. `show print demangle'
  748.      Show whether C++ names will be printed in mangled or demangled
  749.      form.
  750.  
  751. `set print asm-demangle'
  752. `set print asm-demangle on'
  753.      Print C++ names in their source form rather than their mangled
  754.      form, even in assembler code printouts such as instruction
  755.      disassemblies.  The default is off.
  756.  
  757. `show print asm-demangle'
  758.      Show whether C++ names in assembly listings will be printed in
  759.      mangled or demangled form.
  760.  
  761. `set print object'
  762. `set print object on'
  763.      When displaying a pointer to an object, identify the *actual*
  764.      (derived) type of the object rather than the *declared* type,
  765.      using the virtual function table.
  766.  
  767. `set print object off'
  768.      Display only the declared type of objects, without reference to
  769.      the virtual function table.  This is the default setting.
  770.  
  771. `show print object'
  772.      Show whether actual, or declared, object types will be displayed.
  773.  
  774. `set print vtbl'
  775. `set print vtbl on'
  776.      Pretty print C++ virtual function tables.  The default is off.
  777.  
  778. `set print vtbl off'
  779.      Do not pretty print C++ virtual function tables.
  780.  
  781. `show print vtbl'
  782.      Show whether C++ virtual function tables are pretty printed, or
  783.      not.
  784.  
  785. 
  786. File: gdb.info,  Node: Value History,  Next: Convenience Vars,  Prev: Print Settings,  Up: Data
  787.  
  788. Value History
  789. =============
  790.  
  791.    Values printed by the `print' command are saved in GDB's "value
  792. history" so that you can refer to them in other expressions.  Values
  793. are kept until the symbol table is re-read or discarded (for example
  794. with the `file' or `symbol-file' commands).  When the symbol table
  795. changes, the value history is discarded, since the values may
  796. contain pointers back to the types defined in the symbol table.
  797.  
  798.    The values printed are given "history numbers" for you to refer to
  799. them by.  These are successive integers starting with one.  `print'
  800. shows you the history number assigned to a value by printing `$NUM =
  801. ' before the value; here NUM is the history number.
  802.  
  803.    To refer to any previous value, use `$' followed by the value's
  804. history number.  The way `print' labels its output is designed to
  805. remind
  806. you of this.  Just `$' refers to the most recent value in the
  807. history, and `$$' refers to the value before that.  `$$N' refers to
  808. the Nth value from the end; `$$2' is the value just prior to `$$',
  809. `$$1' is equivalent to `$$', and `$$0' is equivalent to `$'.
  810.  
  811.    For example, suppose you have just printed a pointer to a
  812. structure and want to see the contents of the structure.  It
  813. suffices to type
  814.  
  815.      p *$
  816.  
  817.    If you have a chain of structures where the component `next'
  818. points to the next one, you can print the contents of the next one
  819. with this:
  820.  
  821.      p *$.next
  822.  
  823. You can print successive links in the chain by repeating this
  824. command--which you can do by just typing RET.
  825.  
  826.    Note that the history records values, not expressions.  If the
  827. value of `x' is 4 and you type these commands:
  828.  
  829.      print x
  830.      set x=5
  831.  
  832. then the value recorded in the value history by the `print' command
  833. remains 4 even though the value of `x' has changed.
  834.  
  835. `show values'
  836.      Print the last ten values in the value history, with their item
  837.      numbers.  This is like `p $$9' repeated ten times, except that
  838.      `show values' does not change the history.
  839.  
  840. `show values N'
  841.      Print ten history values centered on history item number N.
  842.  
  843. `show values +'
  844.      Print ten history values just after the values last printed.  If
  845.      no more values are available, produces no display.
  846.  
  847.    Pressing RET to repeat `show values N' has exactly the same effect
  848. as `show values +'.
  849.  
  850. 
  851. File: gdb.info,  Node: Convenience Vars,  Next: Registers,  Prev: Value History,  Up: Data
  852.  
  853. Convenience Variables
  854. =====================
  855.  
  856.    GDB provides "convenience variables" that you can use within GDB
  857. to hold on to a value and refer to it later.  These variables exist
  858. entirely within GDB; they are not part of your program, and setting
  859. a convenience variable has no direct effect on further execution of
  860. your program.  That's why you can use them freely.
  861.  
  862.    Convenience variables are prefixed with `$'.  Any name preceded by
  863. `$' can be used for a convenience variable, unless it is one of the
  864. predefined machine-specific register names (*note Registers::.). 
  865. (Value history references, in contrast, are *numbers* preceded by
  866. `$'.  *Note Value History::.)
  867.  
  868.    You can save a value in a convenience variable with an assignment
  869. expression, just as you would set a variable in your program. 
  870. Example:
  871.  
  872.      set $foo = *object_ptr
  873.  
  874. would save in `$foo' the value contained in the object pointed to by
  875. `object_ptr'.
  876.  
  877.    Using a convenience variable for the first time creates it; but
  878. its value is `void' until you assign a new value.  You can alter the
  879. value with another assignment at any time.
  880.  
  881.    Convenience variables have no fixed types.  You can assign a
  882. convenience variable any type of value, including structures and
  883. arrays, even if that variable already has a value of a different
  884. type.  The convenience variable, when used as an expression, has the
  885. type of its current value.
  886.  
  887. `show convenience'
  888.      Print a list of convenience variables used so far, and their
  889.      values.  Abbreviated `show con'.
  890.  
  891.    One of the ways to use a convenience variable is as a counter to
  892. be incremented or a pointer to be advanced.  For example, to print a
  893. field from successive elements of an array of structures:
  894.  
  895.      set $i = 0
  896.      print bar[$i++]->contents
  897.      ... repeat that command by typing RET.
  898.  
  899.    Some convenience variables are created automatically by GDB and
  900. given values likely to be useful.
  901.  
  902. `$_'
  903.      The variable `$_' is automatically set by the `x' command to the
  904.      last address examined (*note Memory::.).  Other commands which
  905.      provide a default address for `x' to examine also set `$_' to
  906.      that address; these commands include `info line' and `info
  907.      breakpoint'.
  908.  
  909. `$__'
  910.      The variable `$__' is automatically set by the `x' command to
  911.      the value found in the last address examined.
  912.  
  913. 
  914. File: gdb.info,  Node: Registers,  Next: Floating Point Hardware,  Prev: Convenience Vars,  Up: Data
  915.  
  916. Registers
  917. =========
  918.  
  919.    You can refer to machine register contents, in expressions, as
  920. variables with names starting with `$'.  The names of registers are
  921. different for each machine; use `info registers' to see the names
  922. used
  923. on your machine.
  924.  
  925. `info registers'
  926.      Print the names and values of all registers except
  927.      floating-point registers (in the selected stack frame).
  928.  
  929. `info all-registers'
  930.      Print the names and values of all registers, including
  931.      floating-point registers.
  932.  
  933. `info registers REGNAME'
  934.      Print the relativized value of register REGNAME.  REGNAME may be
  935.      any register name valid on the machine you are using, with or
  936.      without the initial `$'.
  937.  
  938.    The register names `$pc' and `$sp' are used on most machines for
  939. the program counter register and the stack pointer.  For example,
  940. you could print the program counter in hex with
  941.  
  942.      p/x $pc
  943.  
  944. or print the instruction to be executed next with
  945.  
  946.      x/i $pc
  947.  
  948. or add four to the stack pointer with
  949.  
  950.      set $sp += 4
  951.  
  952. The last is a way of removing one word from the stack, on machines
  953. where stacks grow downward in memory (most machines, nowadays). 
  954. This assumes that the innermost stack frame is selected; setting
  955. `$sp' is not allowed when other stack frames are selected.  (To pop
  956. entire frames off the stack, regardless of machine architecture, use
  957. `return'; *note Returning::..)
  958.  
  959.    Often `$fp' is used for a register that contains a pointer to the
  960. current stack frame, and `$ps' is sometimes used for a register that
  961. contains the processor status.  These standard register names may be
  962. available on your machine even though the `info registers' command
  963. shows other names.  For example, on the SPARC, `info registers'
  964. displays the processor status register as `$psr' but you can also
  965. refer
  966. to
  967. it as `$ps'.
  968.  
  969.    GDB always considers the contents of an ordinary register as an
  970. integer when the register is examined in this way.  Some machines
  971. have special registers which can hold nothing but floating point;
  972. these registers are considered to have floating point values.  There
  973. is no way to refer to the contents of an ordinary register as
  974. floating point value (although you can *print* it as a floating
  975. point value with `print/f $REGNAME').
  976.  
  977.    Some registers have distinct "raw" and "virtual" data formats. 
  978. This means that the data format in which the register contents are
  979. saved by the operating system is not the same one that your program
  980. normally sees.  For example, the registers of the 68881 floating
  981. point coprocessor are always saved in "extended" (raw) format, but
  982. all C programs expect to work with "double" (virtual) format.  In
  983. such cases, GDB normally works with the virtual format only (the
  984. format that makes sense for your program), but the `info registers'
  985. command prints the data in both formats.
  986.  
  987.    Normally, register values are relative to the selected stack frame
  988. (*note Selection::.).  This means that you get the value that the
  989. register would contain if all stack frames farther in were exited
  990. and their saved registers restored.  In order to see the true
  991. contents of hardware registers, you must select the innermost frame
  992. (with `frame 0').
  993.  
  994.    However, GDB must deduce where registers are saved, from the
  995. machine code generated by your compiler.  If some registers are not
  996. saved, or if GDB is unable to locate the saved registers, the
  997. selected stack frame will make no difference.
  998.  
  999. 
  1000. File: gdb.info,  Node: Floating Point Hardware,  Prev: Registers,  Up: Data
  1001.  
  1002. Floating Point Hardware
  1003. =======================
  1004.  
  1005.    Depending on the host machine architecture, GDB may be able to
  1006. give you more information about the status of the floating point
  1007. hardware.
  1008.  
  1009. `info float'
  1010.      If available, provides hardware-dependent information about the
  1011.      floating point unit.  The exact contents and layout vary
  1012.      depending on the floating point chip.
  1013.  
  1014. 
  1015. File: gdb.info,  Node: Cplusplus,  Next: Symbols,  Prev: Data,  Up: Top
  1016.  
  1017. C++ and GDB
  1018. ***********
  1019.  
  1020.    GDB includes facilities to let you debug C++ programs naturally
  1021. and easily.  The GNU C++ compiler and GDB implement the support for
  1022. these facilities together.  Therefore, to debug your C++ code most
  1023. effectively, you must compile your C++ programs with the GNU C++
  1024. compiler, `g++'.
  1025.  
  1026. * Menu:
  1027.  
  1028. * Cplusplus expressions::               C++ Expressions
  1029. * Cplusplus commands::          GDB Commands for C++
  1030.  
  1031. 
  1032. File: gdb.info,  Node: Cplusplus expressions,  Next: Cplusplus commands,  Prev: Cplusplus,  Up: Cplusplus
  1033.  
  1034. C++ Expressions
  1035. ===============
  1036.  
  1037.    Since C++ is closely related to C, all the facilities for
  1038. evaluating C expressions (*note Expressions::.) continue to work in
  1039. C++.  GDB's expression handling also has the following extensions to
  1040. interpret a significant subset of C++ expressions:
  1041.  
  1042.   1. Member function calls are allowed; you can use expressions like
  1043.  
  1044.           count = aml->GetOriginal(x, y)
  1045.  
  1046.   2. While a member function is active (in the selected stack frame),
  1047.      your expressions have the same namespace available as the
  1048.      member function; that is, GDB allows implicit references to the
  1049.      class instance pointer `this' following the same rules as C++.
  1050.  
  1051.   3. You can call overloaded functions; GDB will resolve the function
  1052.      call to the right definition, with one restriction--you must
  1053.      use arguments of the type required by the function that you
  1054.      want to call.  GDB will not perform conversions requiring
  1055.      constructors or user-defined type operators.
  1056.  
  1057.   4. GDB understands variables declared as C++ references; you can
  1058.      use them in expressions just as you do in C++ source--they are
  1059.      automatically dereferenced.
  1060.  
  1061.         In the parameter list shown when GDB displays a frame, the
  1062.      values of reference variables are not displayed (unlike other
  1063.      variables); this avoids clutter, since references are often
  1064.      used for large structures.  The *address* of a reference
  1065.      variable is always shown, unless you've specified `set print
  1066.      address off'.
  1067.  
  1068.   5. GDB supports the C++ name resolution operator `::'--your
  1069.      expressions can use it just as expressions in your program do. 
  1070.      GDB also allows resolving name scope by reference to source
  1071.      files, in both C and C++ debugging; *note Variables::..
  1072.  
  1073. 
  1074. File: gdb.info,  Node: Cplusplus commands,  Prev: Cplusplus expressions,  Up: Cplusplus
  1075.  
  1076. GDB Commands for C++
  1077. ====================
  1078.  
  1079.    Some GDB commands are particularly useful with C++, and some are
  1080. designed specifically for use with C++.  Here is a summary:
  1081.  
  1082. `breakpoint menus'
  1083.      When you want a breakpoint in a function whose name is
  1084.      overloaded, GDB's breakpoint menus help you specify which
  1085.      function definition you want.  *Note Breakpoint Menus::.
  1086.  
  1087. `rbreak REGEX'
  1088.      Setting breakpoints using regular expressions is helpful for
  1089.      setting breakpoints on overloaded functions that are not
  1090.      members of any special classes.  *Note Set Breaks::.
  1091.  
  1092. `catch EXCEPTIONS'
  1093. `info catch'
  1094.      Debug C++ exception handling using these commands.  *Note
  1095.      Exception Handling::.
  1096.  
  1097. `ptype TYPENAME'
  1098.      Print inheritance relationships as well as other information for
  1099.      type TYPENAME.  *Note Symbols::.
  1100.  
  1101. `set print demangle'
  1102. `show print demangle'
  1103. `set print asm-demangle'
  1104. `show print asm-demangle'
  1105.      Control whether C++ symbols display in their source form, both
  1106.      when displaying code as C++ source and when displaying
  1107.      disassemblies.  *Note Print Settings::.
  1108.  
  1109. `set print object'
  1110. `show print object'
  1111.      Choose whether to print derived (actual) or declared types of
  1112.      objects.  *Note Print Settings::.
  1113.  
  1114. `set print vtbl'
  1115. `show print vtbl'
  1116.      Control the format for printing virtual function tables.  *Note
  1117.      Print Settings::.
  1118.  
  1119. 
  1120. File: gdb.info,  Node: Symbols,  Next: Altering,  Prev: Cplusplus,  Up: Top
  1121.  
  1122. Examining the Symbol Table
  1123. **************************
  1124.  
  1125.    The commands described in this section allow you to inquire about
  1126. the symbols (names of variables, functions and types) defined in
  1127. your program.  This information is inherent in the text of your
  1128. program and does not change as the program executes.  GDB finds it
  1129. in your program's symbol table, in the file indicated when you
  1130. started GDB  (*note File Options::.), or by one of the
  1131. file-management commands (*note Files::.).
  1132.  
  1133. `info address SYMBOL'
  1134.      Describe where the data for SYMBOL is stored.  For a register
  1135.      variable, this says which register it is kept in.  For a
  1136.      non-register local variable, this prints the stack-frame offset
  1137.      at which the variable is always stored.
  1138.  
  1139.      Note the contrast with `print &SYMBOL', which does not work at
  1140.      all for a register variables, and for a stack local variable
  1141.      prints the exact address of the current instantiation of the
  1142.      variable.
  1143.  
  1144. `whatis EXP'
  1145.      Print the data type of expression EXP.  EXP is not actually
  1146.      evaluated, and any side-effecting operations (such as
  1147.      assignments or function calls) inside it do not take place. 
  1148.     
  1149.      *Note Expressions::.
  1150.  
  1151. `whatis'
  1152.      Print the data type of `$', the last value in the value history.
  1153.  
  1154. `ptype TYPENAME'
  1155.      Print a description of data type TYPENAME.  TYPENAME may be the
  1156.      name of a type, or for C code it may have the form `struct
  1157.      STRUCT-TAG', `union UNION-TAG' or `enum ENUM-TAG'.
  1158.  
  1159. `ptype EXP'
  1160.      Print a description of the type of expression EXP.  `ptype'
  1161.      differs from `whatis' by printing a detailed description,
  1162.      instead of just the name of the type.  For example, if your
  1163.      program declares a variable as
  1164.  
  1165.           struct complex {double real; double imag;} v;
  1166.  
  1167.      compare the output of the two commands:
  1168.  
  1169.           (gdb) whatis v
  1170.           type = struct complex
  1171.           (gdb) ptype v
  1172.           type = struct complex {
  1173.               double real;
  1174.               double imag;
  1175.           }
  1176.  
  1177. `info types REGEXP'
  1178. `info types'
  1179.      Print a brief description of all types whose name matches REGEXP
  1180.      (or all types in your program, if you supply no argument). 
  1181.      Each complete typename is matched as though it were a complete
  1182.      line; thus, `i type value' gives information on all types in
  1183.      your program whose name includes the string `value', but `i
  1184.      type ^value$' gives information only on types whose complete
  1185.      name is `value'.
  1186.  
  1187.      This command differs from `ptype' in two ways: first, like
  1188.      `whatis', it does not print a detailed description; second, it
  1189.      lists all source files where a type is defined.
  1190.  
  1191. `info source'
  1192.      Show the name of the current source file--that is, the source
  1193.      file for the function containing the current point of execution.
  1194.  
  1195. `info sources'
  1196.      Print the names of all source files in the program for which
  1197.      there is debugging information, organized into two lists: files
  1198.      whose symbols have already been read, and files whose symbols
  1199.      will be read when needed.
  1200.  
  1201. `info functions'
  1202.      Print the names and data types of all defined functions.
  1203.  
  1204. `info functions REGEXP'
  1205.      Print the names and data types of all defined functions whose
  1206.      names contain a match for regular expression REGEXP.  Thus,
  1207.      `info fun step' finds all functions whose names include `step';
  1208.      `info fun ^step' finds those whose names start with `step'.
  1209.  
  1210. `info variables'
  1211.      Print the names and data types of all variables that are
  1212.      declared outside of functions (i.e., excluding local variables).
  1213.  
  1214. `info variables REGEXP'
  1215.      Print the names and data types of all variables (except for
  1216.      local variables) whose names contain a match for regular
  1217.      expression REGEXP.
  1218.  
  1219. `printsyms FILENAME'
  1220.      Write a dump of debugging symbol data into the file FILENAME. 
  1221.      Only symbols with debugging data are included.  GDB includes
  1222.      all the symbols it already knows about: that is, FILENAME
  1223.      reflects symbols for only those files whose symbols GDB has read.
  1224.      You can find out which files these are using the command `info
  1225.      files'.  The description of `symbol-file' describes how GDB
  1226.      reads symbols; both commands are described under *Note Files::.
  1227.  
  1228. 
  1229. File: gdb.info,  Node: Altering,  Next: GDB Files,  Prev: Symbols,  Up: Top
  1230.  
  1231. Altering Execution
  1232. ******************
  1233.  
  1234.    Once you think you have found an error in the program, you might
  1235. want to find out for certain whether correcting the apparent error
  1236. would lead to correct results in the rest of the run.  You can find
  1237. the answer by experiment, using the GDB features for altering
  1238. execution of the program.
  1239.  
  1240.    For example, you can store new values into variables or memory
  1241. locations, give the program a signal, restart it at a different
  1242. address, or even return prematurely from a function to its caller.
  1243.  
  1244. * Menu:
  1245.  
  1246. * Assignment::                  Assignment to Variables
  1247. * Jumping::                     Continuing at a Different Address
  1248. * Signaling::                   Giving the Program a Signal
  1249. * Returning::                   Returning from a Function
  1250. * Calling::                     Calling your Program's Functions
  1251.  
  1252. 
  1253. File: gdb.info,  Node: Assignment,  Next: Jumping,  Prev: Altering,  Up: Altering
  1254.  
  1255. Assignment to Variables
  1256. =======================
  1257.  
  1258.    To alter the value of a variable, evaluate an assignment expression.
  1259. *Note Expressions::.  For example,
  1260.  
  1261.      print x=4
  1262.  
  1263. would store the value 4 into the variable `x', and then print the
  1264. value
  1265. of the assignment expression (which is 4).  All the assignment
  1266. operators of C are supported, including the increment operators `++'
  1267. and `--', and combining assignments such as `+=' and `<<='.
  1268.  
  1269.    If you are not interested in seeing the value of the assignment,
  1270. use
  1271. the `set' command instead of the `print' command.  `set' is really
  1272. the same as `print' except that the expression's value is not
  1273. printed and is not put in the value history (*note Value
  1274. History::.).  The expression is evaluated only for its effects.
  1275.  
  1276.    If the beginning of the argument string of the `set' command
  1277. appears
  1278. identical to a `set' subcommand, use the `set variable' command
  1279. instead of just `set'.  This command is identical to `set' except
  1280. for its lack of subcommands.  For example, a program might well have
  1281. a variable `width'--which leads to an error if we try to set a new
  1282. value with just `set width=13', as we might if `set width' didn't
  1283. happen to be a GDB command:
  1284.  
  1285.      (gdb) whatis width
  1286.      type = double
  1287.      (gdb) p width
  1288.      $4 = 13
  1289.      (gdb) set width=47
  1290.      Invalid syntax in expression.
  1291.  
  1292. The invalid expression, of course, is `=47'.  What we can do in order
  1293. to actually set our program's variable `width' is
  1294.  
  1295.      (gdb) set var width=47
  1296.  
  1297.    GDB allows more implicit conversions in assignments than C does;
  1298. you can freely store an integer value into a pointer variable or
  1299. vice
  1300. versa, and any structure can be converted to any other structure
  1301. that is the same length or shorter.
  1302.  
  1303.    To store values into arbitrary places in memory, use the `{...}'
  1304. construct to generate a value of specified type at a specified
  1305. address (*note Expressions::.).  For example, `{int}0x83040' refers
  1306. to memory location `0x83040' as an integer (which implies a certain
  1307. size and representation in memory), and
  1308.  
  1309.      set {int}0x83040 = 4
  1310.  
  1311. stores the value 4 into that memory location.
  1312.  
  1313.